home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 118 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.3 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: anhaeupl@late.e-technik.uni-erlangen.de (Bernd Anhaeupl)
  3. Newsgroups: comp.std.c++
  4. Subject: order of evaluation
  5. Date: 22 Jan 1996 16:39:42 GMT
  6. Organization: LATE, Uni. Erlangen-Nuernberg, Germany
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4e0dr0$aul@rznews.rrze.uni-erlangen.de>
  9. NNTP-Posting-Host: taumet.eng.sun.com
  10. Content-Type: text
  11. X-Nntp-Posting-Host: late4.e-technik.uni-erlangen.de
  12. Content-Length: 1665
  13. X-Lines: 46
  14. Originator: clamage@taumet
  15.  
  16. In various places the DWP specifies, that the order of evaluation of
  17. some expressions is unspecified. 
  18.  
  19. Some questions:
  20.  
  21. 1.) Does this mean, that for example in the following function call
  22.  
  23.     f(a(...),b(....),c(....));
  24.  
  25.     a(...), b(...), c(...) may even be evaluated in parallel in a
  26.     multitasking environment? 
  27.  
  28.     1a) Is a statement like the one above valid C++, if a(), b()
  29.         and c() are using and modifying the same global variables
  30.         --- What is the exact meaning of "sequence point" in section 5
  31.         paragraph 4 of the april DWP in this context?
  32.  
  33.           static global_variable;
  34.  
  35.           int a(){.....; global_variable++; .....}
  36.           int b(){.....; global_variable++; .....}
  37.           int c(){.....; global_variable++; .....}
  38.  
  39.     Please think of the consequences. Even such basic operations
  40.         like free store management (User defined operator new,...!)
  41.         will access and modify global data (structures).
  42.  
  43. 2.) Is it legal for a compiler to reorder the evaluation of
  44.     the operator new and the constructor calls of some new expressions.
  45.     For example, is it legal for a compiler to evaluate
  46.  
  47.     f(new a(new b()))             or    f2(new a, new b)   (see also question 1)
  48.  
  49.                        in the following order:
  50.  
  51.     tmp1=a::new(sizeof(a));             tmp1=a::new(sizeof(a))
  52.     tmp2=b::new(sizeof(b));             tmp2=b::new(sizeof(b))
  53.     tmp2.b();                           tmp1.a()
  54.     tmp1.a(tmp2);                       tmp2.b() 
  55.     f(tmp1);                            f2(tmp1,tmp2);
  56.  
  57. -- 
  58. Bernd Anhaeupl            Tel.:  +49 9131 857787
  59. LATE - Uni Erlangen            
  60. Cauerstr. 7            Email: anhaeupl@late.e-technik.uni-erlangen.de
  61. 91058 Erlangen
  62.  
  63. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  64.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  65.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  66.  
  67.